﻿using System.Data;

namespace KamLib
{
    public class SessionTransaction : IDbTransaction
    {
        public SessionConnection Connection { get; set; }
        IDbConnection IDbTransaction.Connection { get { return Connection; } }
        public IsolationLevel IsolationLevel { get { return IsolationLevel.ReadCommitted; } }

        public void Dispose()
        {
            if  (Connection.Session.InTransaction)
                Connection.Session.RollbackTransaction();
        }

        public void Commit()
        {
            Connection.Session.CommitTransaction();
        }
        public void Rollback()
        {
            Connection.Session.RollbackTransaction();
        }

    }

}
